package lambda;

/**
 * @author Mark
 * @version 1.0
 * @date 2020/5/23 11:47
 * @description Lamda表达式
 */
public class LambdaClass {


    // 静态内部类
    static class TestLambda2 implements TestLambda {
        @Override
        public void lambda() {
            System.out.println("i like lambda2");
        }
    }

    public static void main(String[] args) {
        TestLambda lambda = new TestImp();
        lambda.lambda();
        TestLambda lambda2 = new TestLambda2();
        lambda2.lambda();


        // 局部内部类
        class TestLambda3 implements TestLambda {
            @Override
            public void lambda() {
                System.out.println("i like lambda3");
            }
        }
        TestLambda lambda3 = new TestLambda3();
        lambda3.lambda();

        // 匿名内部类
        lambda3 = new TestImp() {
            @Override
            public void lambda() {
                System.out.println("i like lambda4");
            }
        };
        lambda3.lambda();

        // lambda表达式
        lambda3 = () -> {
            System.out.println("i like lambda5");
        };
        lambda3.lambda();
    }


}

interface TestLambda {

    /**
     * 测试lambda表达式
     */
    void lambda();
}

class TestImp implements TestLambda {

    @Override
    public void lambda() {
        System.out.println("i like lambda");
    }

}